package me.predatorray.xcollection.common;

import me.predatorray.xcollection.Check;
import me.predatorray.xcollection.Filter;
import me.predatorray.xcollection.Mapper;

public class MapperFilter<E> implements Filter<E> {

    private final Mapper<E, Boolean> mapper;

    public MapperFilter(Mapper<E, Boolean> mapper) {
        Check.isNotNull(mapper, "mapper must not be null");
        this.mapper = mapper;
    }

    @Override
    public boolean filter(E e) {
        return mapper.map(e);
    }
}
